input()
print(max(map(len, (input() * 2).replace(" ", "").split('0'))))
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <stack>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#include <queue>
#include <map>
#include <thread>
#include <list>
#include <bitset>
using namespace std;
///////////////////
#define endl '\n'
#define int long long
#define bd(v) v.begin(),v.end()
#define rbd(v) v.rbegin(),v.rend()
#define cin(v) for(auto& it : v) cin >> it
#define cout(v,/**/x) for(auto it : v) cout << it << x;cout<<endl
#define debug(x) cout<<"[" << #x << " is: " << x << "] "<<endl
#define MAX 9'223'372'036'854'775'807
#define not_less_than(v, n) lower_bound(v.begin(), v.end(), n)
#define index_not_less_than(v, n) lower_bound(v.begin(), v.end(), n) - v.begin()
#define not_more_than(v, n) lower_bound(v.rbegin(), v.rend(), n, greater<int>())
#define index_not_more_than(v, n) lower_bound(v.rbegin(), v.rend(), n, greater<int>()) - v.begin()
#define more_than(v, n) upper_bound(v.begin(), v.end(), n)
#define index_more_than(v, n) upper_bound(v.begin(), v.end(), n) - v.begin()
#define less_than(v, n) upper_bound(v.rbegin(), v.rend(), n, greater<int>())
#define index_less_than(v, n) upper_bound(v.rbegin(), v.rend(), n, greater<int>()) - v.begin()
#define sort_pair_second(v) sort(v.begin(), v.end(), [](const auto &a, const auto &b) { return a.second < b.second; });
#define rsort_pair_second(v) sort(v.rbegin(), v.rend(), [](const auto &a, const auto &b) { return a.second < b.second; });
bool prime(int a) { if (a < 2)return false;for (int i = 2; i * i <= a; i++) { if (a % i == 0)return false; }return true; }
//HINTS: Reset sum, max, min;
void solve();
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int test_cases = 1;
//cout << "Test Cases!\n";
//cin >> test_cases;
while (test_cases--) solve();
}
// بسم الله الرحمن الرحيم //
// اللهم صل وسلم على سيدنا محمد //
void solve() {
int n, front = 0, back = 0, mid = 0, sum = 0, flag = 1; cin >> n;
vector<int>v(n);
for (int i = 0 ; i < n; i++) {
cin >> v[i];
if(i == n - 1 && v[i])
back = sum + 1;
if (v[i]) {
sum++;
}
else {
mid = max(sum, mid);
sum = 0;
}
if(flag && v[i])
front++;
else flag = 0;
}
cout << max ({front + back, mid}) << endl;
}
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |
60. Permutation Sequence | 42. Trapping Rain Water |
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |
AND path in a binary tree | Factorial equations |
Removal of vertices | Happy segments |
Cyclic shifts | Zoos |
Build a graph | Almost correct bracket sequence |
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |
Partitioning binary strings | Special sets |
Smallest chosen word | Going to office |
Color the boxes | Missing numbers |